 /*****************************************************************************
 * print_page.js                                                              *
 * Last Modified: 2007-06-04                                                  *
 *                                                                            *
 * BBG_Billing, a PHP application using MySQL for creating and maintaining a  *
 * contacts and invoices database.                                            *
 *                                                                            *
 * @copyright Copyright (C) 2007, Bugs Bee Gone Computer Services             *
 * @owner     Daniel Barnett (Bugs Bee Gone Computer Services)                *
 * @author    Daniel Barnett <dbarnett@bugsbeegone.com>                       *
 * @website   http://www.bugsbeegone.com                                      *
 * @license   http://www.gnu.org/licenses/gpl.html GNU General Public License *
 * @package   BBG_Billing                                                     *
 * @name      print_page.js                                                   *
 * @version   1.0.0                                                           *
 *                                                                            *
 * This file is part of the "BBG_Billing" PHP application.                    *
 *                                                                            *
 * BBG_Billing is free software; you can redistribute it and/or modify        *
 * it under the terms of the GNU General Public License as published by       *
 * the Free Software Foundation; either version 2 of the License, or          *
 * (at your option) any later version.                                        *
 *                                                                            *
 * BBG_Billing is distributed in the hope that it will be useful,             *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU General Public License for more details.                               *
 *                                                                            *
 * You should have received a copy of the GNU General Public License          *
 * along with BBG_Billing; if not, write to the Free Software                 *
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA *
 *****************************************************************************/
 
 
// Usage Example:
//     function printPage() {
//		     createPage(document.getElementById("invoice").innerHTML, "http://www.bugsbeegone.com", "Bugs Bee Gone - Billing - ' . $invoiceNum . '", "");
//     }

//     <input type="button" onclick="printPage()" value="Print" name="printButton" />


// Declare global variables
var winPrint;
var docPrint;

// Declare public function createPage
// Called from the HTML page
function createPage(contents, domain, title, header) {
    // Call function createSizedPage
    createSizedPage(contents, domain, title, header, 800, 600);
}

// Declare private function createSizedPage
function createSizedPage(contents, domain, title, header, width, height)
{
    winPrint=window.open("","PrintWin","toolbar=0,status=0,menubar=0,fullscreen=no,width="+width+",height="+height+",resizable=0,top=5,left=5");
    winPrint.focus();
    docPrint=winPrint.document;

    docPrint.open();
    docPrint.writeln('<html>');
    docPrint.writeln('<head>');
    if (title != null && title.length > 0) docPrint.writeln('<title>'+title+'</title>');
    docPrint.writeln('<script>');
    docPrint.writeln('var winMain=window.opener;');
    docPrint.writeln('</script>');
    docPrint.writeln('<link href="'+domain+'/billing/invoice.css" type="text/css" rel="stylesheet" />');
    docPrint.writeln('</head>');
    docPrint.writeln('<body>');
    if(header != null && header.length > 0) docPrint.writeln('<div class="page_header">'+header+'</div>');
    docPrint.writeln('<div id="content">'+contents+'</div>');
    docPrint.writeln('</body>');
    docPrint.writeln('</html>');
    docPrint.close();
    winPrint.print();
    winPrint.close();
}
